import { defHttp } from '/@/utils/http/axios';
import { PageResult } from '@/api/model/pageResult';
import { ContentTypeEnum } from '@/enums/httpEnum';
import { QueryMarketingLimitpriceBo } from '@/api/promotions/limitprice/model/queryMarketingLimitpriceBo';
import { QueryMarketingLimitpriceVo } from '@/api/promotions/limitprice/model/queryMarketingLimitpriceVo';
import { GetMarketingLimitpriceBo } from '@/api/promotions/limitprice/model/getMarketingLimitpriceBo';
import { CreateMarketingLimitpriceVo } from '@/api/promotions/limitprice/model/createMarketingLimitpriceVo';
import { UpdateMarketingLimitpriceVo } from '@/api/promotions/limitprice/model/updateMarketingLimitpriceVo';

const baseUrl = '/promo/limitprice';
const region = 'cloud-api';

/**
 * 查询列表
 * @param params
 * @returns {Promise}
 */
export function query(
  params: QueryMarketingLimitpriceVo,
): Promise<PageResult<QueryMarketingLimitpriceBo>> {
  return defHttp.get<PageResult<QueryMarketingLimitpriceBo>>(
    {
      url: baseUrl + '/query',
      params: params,
    },
    {
      region,
    },
  );
}

/**
 * 根据ID查询
 * @param id
 * @returns {Promise}
 */
export function get(id: String): Promise<GetMarketingLimitpriceBo> {
  return defHttp.get<GetMarketingLimitpriceBo>(
    {
      url: baseUrl,
      params: {
        id,
      },
    },
    {
      region,
    },
  );
}

/**
 * 新增
 * @param params
 * @returns {Promise}
 */
export function create(params: CreateMarketingLimitpriceVo): Promise<void> {
  return defHttp.post<void>(
    {
      url: baseUrl,
      data: params,
    },
    {
      contentType: ContentTypeEnum.JSON,
      region,
    },
  );
}

/**
 * 修改
 * @param params
 * @returns {Promise}
 */
export function update(params: UpdateMarketingLimitpriceVo): Promise<void> {
  return defHttp.put<void>(
    {
      url: baseUrl,
      data: params,
    },
    {
      contentType: ContentTypeEnum.JSON,
      region,
    },
  );
}
